package com.example.learn_gl_android.anglib.util.math

import org.junit.Before
import org.junit.Test


import org.junit.jupiter.api.Assertions.assertEquals


class Vector2Test {
    private val x = Vector2()
    private val y = Vector2()

    @Before
    fun setUp() {
        x.elements[0] = 1f
        x.elements[1] = 2f

        y.elements[0] = 3f
        y.elements[1] = 4f
    }


    @Test
    fun plus() {
        val res = x + y

        assertEquals(4f, res.elements[0])
        assertEquals(6f, res.elements[1])
    }

    @Test
    fun plusAssign() {
        val res = Vector2()
        res += x;
        assertEquals(x.elements[0], res.elements[0])
        assertEquals(x.elements[1], res.elements[1])
    }

    @Test
    fun minus() {
        val res = x - y

        assertEquals(-2f, res.elements[0])
        assertEquals(-2f, res.elements[1])
    }

    @Test
    fun minusAssign() {
        val res = Vector2()
        res -= x;
        assertEquals(-1f, res.elements[0])
        assertEquals(-2f, res.elements[1])
    }

    @Test
    fun copy() {
        val res = x.copy()
        assertEquals(x.elements[0], res.elements[0])
        assertEquals(x.elements[1], res.elements[1])
    }
}